package com.example.demo2.controller;


import com.example.demo2.entity.Graduate_Demands;
import com.example.demo2.service.Graduate_DemandsService;
import com.google.gson.Gson;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/lv_graduate_demands")
public class Graduate_DemandsController {

    @Autowired
    private Graduate_DemandsService graduate_demandsService;
//    graduation_requirments, graduate_demands, graduation_requirments_contents
//     private String graduationRequirments;
//
//    private Integer graduateDemands;
//
//    private String graduationRequirmentsContents;

//    显示所有的毕业指标点
    @RequestMapping("/selectAllGrad_points")
    public String selectAllGrad_points()
    {
        List<Graduate_Demands> list=graduate_demandsService.Lv_selectAllGrad_points();
        Gson gson = new Gson();
        return gson.toJson(list);
    }

//     根据毕业要求指标点来显示
    @RequestMapping("/selectByGrad_Id")
    public Graduate_Demands selectByGrad_Id(@Param("graduation_requirments") String graduationRequirments)
    {
        return graduate_demandsService.Lv_selectByGrad_Id(graduationRequirments);
    }


//根据指标点ID删除记录
    @RequestMapping("/deleteByGrad_Id")
    public int deleteByGrad_Id(@Param("graduation_requirments") String graduationRequirments)
    {
       return graduate_demandsService.Lv_deleteByGrad_Id(graduationRequirments);
    }

//    增加一个毕业要求指标点
    @RequestMapping("/insertGrad_Id")
    public int insertGrad_Id(@Param("graduate_demands") Integer graduateDemands,@Param("graduation_requirments") String graduationRequirments,
                              @Param("graduationRequirmentsContents") String graduationRequirmentsContents)
    {
        Graduate_Demands graduate_demands=new Graduate_Demands();
        graduate_demands.setGraduateDemands(graduateDemands);
        graduate_demands.setGraduationRequirments(graduationRequirments);
        graduate_demands.setGraduationRequirmentsContents(graduationRequirmentsContents);

        return graduate_demandsService.Lv_insertGrad_Id(graduate_demands);
    }

    @RequestMapping("/updateByGrad_Id")
    public int updateByGrad_Id(@Param("graduate_demands") Integer graduateDemands,@Param("graduation_requirments") String graduationRequirments,
                                @Param("graduationRequirmentsContents") String graduationRequirmentsContents)
    {
        Graduate_Demands graduate_demands=new Graduate_Demands();
        graduate_demands.setGraduateDemands(graduateDemands);
        graduate_demands.setGraduationRequirments(graduationRequirments);
        graduate_demands.setGraduationRequirmentsContents(graduationRequirmentsContents);

         return graduate_demandsService.Lv_updateByGrad_Id(graduate_demands);
    }





}
